package com.coldchain.configuration;


import com.baomidou.mybatisplus.annotation.DbType;
import com.baomidou.mybatisplus.core.injector.ISqlInjector;
import com.baomidou.mybatisplus.extension.injector.LogicSqlInjector;
import com.baomidou.mybatisplus.extension.plugins.PaginationInterceptor;
import com.baomidou.mybatisplus.extension.plugins.PerformanceInterceptor;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.transaction.annotation.EnableTransactionManagement;

/**
 * mybtis 配制文件
 * @ClassName MybatisPlusConfig
 * @Description
 * @Author fangliai
 * @Date 2018/8/28 15:33
 * @Vesion 1
**/
 @EnableTransactionManagement
 @Configuration
 @MapperScan({"com.coldchain.admin.**.mapper","com.coldchain.customer.mapper"})
public class MybatisPlusConfig {
    /**
     * mybatis-plus SQL执行效率插件【生产环境可以关闭】
     */
    @Bean
    public PerformanceInterceptor performanceInterceptor() {
        return new PerformanceInterceptor();
    }
    /**
     * mybatis-plus分页插件<
     */
    @Bean
    public PaginationInterceptor paginationInterceptor() {
        PaginationInterceptor paginationInterceptor = new PaginationInterceptor();
        paginationInterceptor.setDialectType(DbType.MYSQL.getDb());

        return paginationInterceptor;
    }
    @Bean
    public ISqlInjector sqlInjector(){
        return new LogicSqlInjector();
    }
}
